package com.aabte.feignhttp.springmvcdemo.common.config;

import com.aabte.feignhttp.feignfastjson.FastJsonDecoder;
import com.aabte.feignhttp.feignfastjson.FastJsonEncoder;
import com.aabte.feignhttp.springmvcfeignhttpclient.SpringMvcContract;
import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.httpclient.ApacheHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Daniel
 */
@Configuration
public class MainConfig {

    @Bean
    public Feign.Builder feignHttpBuilder() {
        return Feign.builder().encoder(new FastJsonEncoder()).decoder(new FastJsonDecoder())
                .client(new ApacheHttpClient())
                .options(new Request.Options(1000, 3500))
                .retryer(new Retryer.Default(5000, 5000, 3))
                .contract(new SpringMvcContract());
    }

}
